<template>
    <table>
        <tr>
            <td>门店名称</td>
            <td>
                <input type="text" v-model="info.Name" placeholder="请输入门店名称">
            </td>
        </tr>
        <tr>
            <td>分店名称</td>
            <td>
                <input type="text" v-model="info.FdName" placeholder="请输入分店名称">
            </td>
        </tr>
        <tr>
            <td>门店电话</td>
            <td>
                <input type="text" v-model="info.Phone" placeholder="请输入门店电话">
            </td>
        </tr>
        <tr>
            <td>门店地址</td>
            <td>
                <input type="text" v-model="info.AddRess" placeholder="请输入门店地址">
            </td>
        </tr>
        <tr>
            <td>交通信息</td>
            <td>
                <input type="text" v-model="info.Jtinfo" placeholder="请输入交通信息">
            </td>
        </tr>
        <tr>
            <td>状态</td>
            <td>
                <input type="radio" v-model="info.Status" :value="true">营业中
                <input type="radio" v-model="info.Status" :value="false">已歇业
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button"  value="门店修改" @click="Saveadd">
            </td>
        </tr>
    </table>
    </template>
    
    <script setup lang="ts">
    import {onMounted,ref} from 'vue'
    import {useRoute,useRouter} from 'vue-router'
    import axios from 'axios';
    const rou=useRoute();
const rouser=useRouter();
    
    const info=ref({
     
      "Name": "",
      "FdName": "",
      "Phone": "",
      "AddRess": "",
      "Jtinfo": "",
      "Status": true
    })
    onMounted(()=>{
        fantian()
    })
    const fantian=()=>{
        axios.get("https://localhost:7224/api/Shop/GetShopByid",{
            params:{
                id:rou.params.id
            }
        })
        .then(res=>{
            info.value=res.data
        })
    }
    const Saveadd=()=>{
    if(info.value.Name==""){
        alert("门店名称不能为空");
    return;
    }
    
    if(info.value.Phone==""){
        alert("门店电话不能为空");
    return;
    }
    if(info.value.Jtinfo==""){
        alert("门店交通不能为空");
    return;
    }
    if(info.value.AddRess==""){
        alert("门店地址不能为空");
    return;
    }
    axios.post("https://localhost:7224/api/Shop/AddShop",info.value)
    .then(res=>{
        if(res.data>0){
            alert("修改成功");
    
        }else{
            alert("修改失败");
        }
    })
    
    }
    </script>
    
    <style scoped>
    
    </style>